package com.it.emall.controller;


import com.it.emall.domain.Recipes;


import com.it.emall.service.NutritionInfoService;
import com.it.emall.utils.JwtHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/nutrition")
public class NutritionInfoController {
//自动生成
    @Autowired
    private NutritionInfoService nutritionInfoService;

    @PostMapping("/generatea")
    public List<Recipes> generateRecipes(@RequestHeader("token") String token,
                                         @RequestParam int calories,
                                         @RequestParam int protein,
                                         @RequestParam int fat,
                                         @RequestParam int carbohydrate) {
        Integer userId = JwtHelper.verifyTokenAndGetUserId(token);
        return nutritionInfoService.generateRecipes(userId, calories, protein, fat, carbohydrate);
    }
}
